package test6.publics;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

import test6.pages.LoginPage;

public class LoginUser {
	//登录方法
		public static void login(WebDriver driver,String username,String password){
			//driver.switchTo().frame(driver.findElement(By.name("body")));
			//driver.switchTo().frame(driver.findElement(By.name("navbar")));
			driver.switchTo().frame("body");
			driver.switchTo().frame("navbar");
			LoginPage.login_UserName(driver).clear();
			LoginPage.login_UserName(driver).sendKeys(username);
			LoginPage.login_Password(driver).clear();
			LoginPage.login_Password(driver).sendKeys(password);
			LoginPage.login_submit(driver).click();
		}
		
	public static void register(WebDriver driver,String username,String password,String passwordConfirm,String firstName,String lastName,String address1,String address2){
		driver.switchTo().frame(driver.findElement(By.name("body")));
		driver.switchTo().frame(driver.findElement(By.name("info")));
		LoginPage.register_11(driver).click();
		LoginPage.register_UserName(driver).clear();
		LoginPage.register_UserName(driver).sendKeys(username);
		LoginPage.register_Password(driver).clear();
		LoginPage.register_Password(driver).sendKeys(password);
		LoginPage.register_passwordConfirm(driver).clear();
		LoginPage.register_passwordConfirm(driver).sendKeys(passwordConfirm);
		LoginPage.register_firstName(driver).clear();
		LoginPage.register_firstName(driver).sendKeys(firstName);
		LoginPage.register_lastName(driver).clear();
		LoginPage.register_lastName(driver).sendKeys(lastName);
		LoginPage.register_address1(driver).clear();
		LoginPage.register_address1(driver).sendKeys(address1);
		LoginPage.register_address2(driver).clear();
		LoginPage.register_address2(driver).sendKeys(address2);
		LoginPage.register_register(driver).click();
	
	}
}
